package da.asclass.component
{
    import mx.containers.Canvas;
    import mx.containers.ControlBar;
    import mx.containers.HBox;
    import mx.containers.VBox;
    import mx.controls.Button;
    import mx.controls.Image;
    import mx.controls.Label;
    import mx.controls.Spacer;
    import mx.controls.TextArea;

    public class ChatCanvas extends Canvas
    {
        private var vbCanvas:VBox = null;
        private var hbTitle:HBox = null;
        private var lblTitle:Label = null;
        private var spTitle:Spacer = null;
        private var imgTitleMin:Image = null;
        private var imgTitleMax:Image = null;
        private var imgTitleClose:Image = null;

        private var txtReceivedInfo:TextArea = null;
        private var canTool:Canvas = null;
        private var txtSendInfo:TextArea = null;

        private var hbControlBar:HBox = null;
        private var controlBar:ControlBar = null;
        private var btnClose:Button = null;
        private var spControlBar:Spacer = null;
        private var btnSend:Button = null;

        public function ChatCanvas()
        {
            super();
            this.width = 400;
            this.height = 360;
            this.horizontalScrollPolicy = 'false';
            this.verticalScrollPolicy = 'false';

            this.vbCanvas = new VBox();
            this.vbCanvas.x = 3;
            this.vbCanvas.y = 2;
            this.vbCanvas.width = 394;
            this.vbCanvas.height = 356;

            this.hbTitle = new HBox();
            this.width = 394;
            this.height = 25;

            this.lblTitle = new Label();
            this.lblTitle.width = 150;
            this.lblTitle.maxWidth = 150;
            this.lblTitle.text = "userName";
            this.spTitle = new Spacer();
            this.spTitle.width = 150;
            this.imgTitleMin = new Image(); //argument is needed
            this.imgTitleMax = new Image();
            this.imgTitleClose = new Image();

            this.txtReceivedInfo = new TextArea();
            this.txtReceivedInfo.width = 394;
            this.txtReceivedInfo.height = 170;
            this.txtReceivedInfo.editable = false;
            this.canTool = new Canvas();
            this.canTool.width = 394;
            this.canTool.height = 20;
            this.txtSendInfo = new TextArea();
            this.txtSendInfo.width = 394;
            this.txtSendInfo.height = 90;

            this.hbControlBar = new HBox();
            this.hbControlBar.width = 394;
            this.hbControlBar.height = 25;
            this.hbControlBar.horizontalScrollPolicy = "false";
            this.hbControlBar.verticalScrollPolicy = "false";

            this.btnClose = new Button();
            this.btnClose.width = 50;
            this.btnClose.height = 23;
            this.btnClose.label = "Close";

            this.spControlBar = new Spacer();
            this.spControlBar.width = 10;
            this.btnSend = new Button();
            this.btnSend.width = 50;
            this.btnSend.height = 23;
            this.btnSend.label = "Send";
        }

        protected override function createChildren():void
        {
            this.hbTitle.addChild(this.lblTitle);
            this.hbTitle.addChild(this.spTitle);
            this.hbTitle.addChild(this.imgTitleMin);
            this.hbTitle.addChild(this.imgTitleMax);
            this.hbTitle.addChild(this.imgTitleClose);
            this.vbCanvas.addChild(this.hbTitle); //add title to canvas

            this.vbCanvas.addChild(this.txtReceivedInfo);
            this.vbCanvas.addChild(this.canTool);
            this.vbCanvas.addChild(this.txtSendInfo);

            this.controlBar.addChild(this.btnClose);
            this.controlBar.addChild(this.spControlBar);
            this.controlBar.addChild(this.btnSend);
            this.hbControlBar.addChild(this.controlBar);
        }
    }
}

